package com.xuecheng.manage_cms;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author gongfeiyue
 * @date 2020/5/18 11:06
 * @Description   启动类，启动过程中会扫描Bean并注入spring 容器
 */
@SpringBootApplication
@EnableDiscoveryClient // Eureka客户端
@EntityScan("com.xuecheng.framework.domain.cms")//扫描实体类
@ComponentScan(basePackages={"com.xuecheng.api"})//扫描接口
@ComponentScan(basePackages={"com.xuecheng.manage_cms"})//扫描本项目下的所有类 （不加也可以扫描，因为默认就是扫描manage_cms下面的包）
@ComponentScan(basePackages = {"com.xuecheng.framework"}) // 会扫描到common下的Exception 解决ExceptionCast 报空指针的问题
public class ManageCmsApplication {

  public static void main(String[] args) {
    SpringApplication.run(ManageCmsApplication.class,args);
  }

  @Bean
  //@LoadBalanced //开启客户端负载均衡 这时ribbion才具有客户端负载均衡的功能
  public RestTemplate restTemplate(){
    return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
  }

}
